package com.xyw.code.gateway.common.entity.enums;

import com.xyw.code.common.core.constant.ConstantStatusInterface;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: xuyiwei
 * Date: 2020/2/5
 * Time: 下午3:35
 * Email: 1328312923@qq.com
 * Description: No Description
 **/
public enum  RouteDefinitionMessageTagEnum implements ConstantStatusInterface {

    ADD(0,"新增"),
    UPDATE(1,"更新"),
    DEL(2,"删除"),
    ;

    final static Map<Integer, RouteDefinitionMessageTagEnum> cache = new HashMap<Integer, RouteDefinitionMessageTagEnum>();

    static {
        for(RouteDefinitionMessageTagEnum routeDefinitionMessageTagEnum:RouteDefinitionMessageTagEnum.values()){
            cache.put(routeDefinitionMessageTagEnum.key,routeDefinitionMessageTagEnum);
        }
    }

    private Integer key;
    private String desc;

    RouteDefinitionMessageTagEnum(Integer key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public static RouteDefinitionMessageTagEnum get(Integer key) {
        return cache.get(key);
    }

    public Integer getKey() {
        return key;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(Integer key) {
        RouteDefinitionMessageTagEnum e = get(key);
        return e != null ? e.getDesc() : null;
    }
}
